package com.ruoyi.project.men.service.impl;


import com.github.pagehelper.PageInfo;
import com.ruoyi.common.utils.bootdo.PageHelperUtils;
import com.ruoyi.common.utils.bootdo.R;
import com.ruoyi.project.men.dao.MenRelatedCaseDao;
import com.ruoyi.project.men.dao.MenRelatedGoodsDao;
import com.ruoyi.project.men.dao.MenSolutionDao;
import com.ruoyi.project.men.domain.MenSolutionDO;
import com.ruoyi.project.men.service.MenSolutionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service
public class MenSolutionServiceImpl implements MenSolutionService {
	@Autowired
	private MenSolutionDao menSolutionDao;
	@Autowired
	private MenRelatedCaseDao menRelatedCaseDao;
	@Autowired
	private MenRelatedGoodsDao menRelatedGoodsDao;
	
	@Override
	public MenSolutionDO get(String id){
		return menSolutionDao.get(id);
	}
	
	@Override
	public List<MenSolutionDO> list(Map<String, Object> map){
		return menSolutionDao.list(map);
	}
	
	@Override
	public int count(Map<String, Object> map){
		return menSolutionDao.count(map);
	}
	
	@Override
	public int save(MenSolutionDO menSolution){
		return menSolutionDao.save(menSolution);
	}
	
	@Override
	public int update(MenSolutionDO menSolution){
		return menSolutionDao.update(menSolution);
	}
	
	@Override
	public int remove(String id){
		return menSolutionDao.remove(id);
	}
	
	@Override
	public int batchRemove(String[] ids){
		return menSolutionDao.batchRemove(ids);
	}

    @Override
    public List<MenSolutionDO> likeList(Map<String, Object> map){
        return menSolutionDao.likeList(map);
    }
    @Override
    public int likeListCount(Map<String, Object> map){
        return menSolutionDao.likeListCount(map);
    }

    @Override
    public R getSolutionImgurlList(Map<String, Object> params) {
		PageHelperUtils.page(params);
		List<Map<String,Object>> list = menSolutionDao.getSolutionImgurlList(params);
		PageInfo<Map<String,Object>> pageInfo = new PageInfo<>(list);
		return R.ok().put("data",pageInfo);

    }

	@Override
	public R getSolutionInfo(Map<String, Object> params) {
		//解决方案详情
		MenSolutionDO menSolutionDO = menSolutionDao.get(params.get("solutionId").toString());
		Map<String,Object> map = new HashMap<>();
		map.put("status","1");
		//项目案例
		map.put("parentId",params.get("solutionId").toString());
		List<Map<String,Object>> productCaseList = menRelatedCaseDao.getCaseByProductId(map);
		//相关产品
		List<Map<String,Object>> productGoodsList = menRelatedGoodsDao.getGoodsByProductId(map);
		Map<String,Object> data = new HashMap<>();
		data.put("menSolutionDO",menSolutionDO);
		data.put("solutionCaseList",productCaseList);
		data.put("solutionGoodsList",productGoodsList);
		return R.ok().put("data",data);
	}

}
